import { Loading, MessageBox } from 'element-ui'
let loadingInstance
const menu0 = [
  {
    type: 0,
    index: '5',
    class: 'el-icon-third-company',
    title: '公司管理',
    submenu: [
      { index: 'companyAudit', title: '公司审核' },
      { index: 'caseAudit', title: '方案审核' },
      { index: 'designAudit', title: '设计师审核' }
    ]
  },
  {
    type: 0,
    index: '7',
    class: 'el-icon-third-msnui-ad',
    title: '广告管理',
    submenu: [
      { index: 'adList', title: '广告列表' },
      { index: 'adAdd', title: '广告新增' }
    ]
  },
  {
    type: 0,
    index: '9',
    class: 'el-icon-third-huiyuan',
    title: '会员管理',
    submenu: [
      { index: 'customerAudit', title: '会员审核' },
      { index: 'customerList', title: '会员需求' }
    ]
  }
]
const menu1 = [
  {
    type: 0,
    index: '1',
    class: 'el-icon-third-yonghu',
    title: '用户管理',
    submenu: [
      { index: 'userList', title: '用户列表' },
      { index: 'userAdd', title: '用户新增' }
    ]
  },
  {
    type: 0,
    index: '17',
    class: 'el-icon-third-gongsi',
    title: '公司用户',
    submenu: [
      { index: 'companyuserList', title: '公司用户列表' },
      { index: 'companyuserAdd', title: '公司用户新增' }
    ]
  },
  {
    type: 0,
    index: '3',
    class: 'el-icon-third-zhongduancanshuguanli',
    title: '参数设置',
    submenu: [
      { index: 'paramList', title: '参数列表' },
      { index: 'paramAdd', title: '参数新增' }
    ]
  },
  {
    type: 0,
    index: '5',
    class: 'el-icon-third-company',
    title: '公司管理',
    submenu: [
      { index: 'companyAudit', title: '公司审核' },
      { index: 'caseAudit', title: '方案审核' },
      { index: 'designAudit', title: '设计师审核' }
    ]
  },
  {
    type: 0,
    index: '7',
    class: 'el-icon-third-msnui-ad',
    title: '广告管理',
    submenu: [
      { index: 'adList', title: '广告列表' },
      { index: 'adAdd', title: '广告新增' }
    ]
  },
  {
    type: 0,
    index: '9',
    class: 'el-icon-third-huiyuan',
    title: '会员管理',
    submenu: [
      { index: 'customerAudit', title: '会员审核' },
      { index: 'customerList', title: '会员需求' }
    ]
  },
  { type: 1, index: 'LogList', class: 'el-icon-third-chayuerizhi', title: '日志管理' }
]
export default {
  menu0,
  menu1,
  open: function () {
    loadingInstance = Loading.service({
      lock: true,
      text: 'Loading',
      spinner: 'el-icon-loading',
      background: 'rgba(0, 0, 0, 0.7)'
    })
  },
  close: function () {
    loadingInstance.close()
  },
  messageTwo (message, title) {
    MessageBox.alert(message, title, {
      confirmButtonText: '确定'
    })
  },
  catchbox (that) {
    that.$pub.close()
    that.$router.push({ name: 'login' })
    // MessageBox.alert('登录超时，请退出重新登录', '提示信息', {
    //   confirmButtonText: '确定',
    //   callback: action => {
    //   }
    // })
  },
  failcode (that, code, message) {
    if (code === 401) {
      MessageBox.alert('登录超时，请退出重新登录', '提示信息', {
        confirmButtonText: '确定',
        callback: action => {
          that.$router.push({ name: 'login' })
        }
      })
    }
    if (code === -1) {
      MessageBox.alert(message, '提示信息', {
        confirmButtonText: '确定'
      })
    }
  }
}
